﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WordGame.Question;
using System.Collections;
namespace WordGame.Answer
{
    class Edward : IWordGame
    {
        public int getCheater(string[] first, string[] second, string[] third)
        {
            //init
            string[] array = new string[first.Length + second.Length + third.Length + 1];
            int p = 0;
            //row
            for (int i = 0; i < first.Length; i++)
            {
                //column
                for (int j = 0; j < 3; j++)
                {
                    switch (j)
                    {
                        case 0:
                            array[p] = first[i];
                            ++p;
                            break;
                        case 1:
                            try
                            {
                                array[p] = second[i];
                                ++p;
                            }
                            catch { }
                            break;
                        case 2:
                            try
                            {
                                array[p] = third[i];
                                ++p;
                            }
                            catch { }
                            break;
                        default: throw new Exception();
                    }

                }
            }

            for (int m = 0; m < array.Length; m++)
            {
                string curStr = array[m];
                string nextStr;
                if (array[m + 1] != null)
                {
                    nextStr = array[m + 1];
                }
                else
                { break; }
                string left = nextStr.Substring(1);
                string right = nextStr.Remove(nextStr.Length - 1);
                if ((curStr == left) || (curStr == right))
                {

                }
                else
                {
                    return (array.Length % 3) + 1;
                }


            }

            return -1;
        }
    }
}
